/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * main.c
 * Copyright (C) Maxim Ermilov 2009 <zaspire@rambler.ru>
 * 
 * main.c is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * main.c is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <gjs/gjs.h>
#include "debug.h"
#include <girepository.h>

int main(int argc, char **argv)
{
	GjsContext *gjs_context;
 	const char *js_dir;
	char **search_path;
	GError *error = NULL;
	int status;

	g_type_init ();
	g_irepository_prepend_search_path (TYPELIBDIR);

	js_dir = JSDIR":.";

	search_path = g_strsplit(js_dir, ":", -1);
	gjs_context = gjs_context_new_with_search_path(search_path);

	debug_init (&argc, &argv, gjs_context);

	if (!gjs_context_eval (gjs_context,
                         "const Main = imports.main; Main.start();",
                         -1, "<main>", &status, &error))
 	{
 		g_warning ("Evaling main.js failed: %s", error->message);
 		g_error_free (error);
    }
	g_strfreev (search_path);
	return 0;
}
